package cn.lysj.framework.common.domain;

import cn.lysj.framework.base.BaseEntity;
import cn.lysj.framework.common.RelationType;
import cn.lysj.framework.common.annotation.Relation;
import cn.lysj.framework.common.validate.annotation.NotBlank;
import cn.lysj.framework.common.validate.annotation.Pattern;
import cn.lysj.framework.common.validate.annotation.Unique;
import cn.lysj.framework.store.domain.Store;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Transient;
import java.util.List;

/**
 * @author zk
 * @description 用户表
 * @create 2018-07-25 14:55
 **/
@Data
@Entity
@EqualsAndHashCode(callSuper = true)
public class User extends BaseEntity {
    @Pattern(pattern = "[a-zA-Z0-9_]{5,15}", message = "用户名应为英文、数字、下划线组成的5-15位字符")
    private String username;//用户名，登录账号，必填

    @Pattern(pattern = "[a-zA-Z0-9_]{6,15}", message = "密码应为英文、数字、下划线组成的6-15位字符")
    private String password;//密码 必填

    private String phone;//联系电话 选用

    //    @Email
    private String email;//邮箱 选用

    private String avatar;//用户头像 选用

    @Transient
    private List<Permission> permissions;//用户拥有的权限

    @Transient
    private List<Role> roles;//用户拥有的角色

    private String storeId; // 所属门店Id

    @Transient
    @Relation(relationType = RelationType.ONE, idProperty = "storeId", serviceName = "storeService")
    private Store store;

    //-------------微信相关配置信息-----------------------
    @Column(columnDefinition = "TEXT")
    private String mchId; //商户号

    @Column(columnDefinition = "TEXT")
    private String appKey; //秘钥

    @Column(columnDefinition = "TEXT")
    private String attach; //授权码

    @Column(columnDefinition = "TEXT")
    private String orgNo; //机构号

    @Column(columnDefinition = "TEXT")
    private String deviceInfo; //终端号

    //-------------阿里相关配置信息-----------------------
    @Column(columnDefinition = "TEXT")
    private String aliAppId;

    @Column(columnDefinition = "TEXT")
    private String aliAppPrivateKey;

    @Column(columnDefinition = "TEXT")
    private String aliAppPublicKey;

    @Column(columnDefinition = "TEXT")
    private String aliNotifyUrl;

    @Column(columnDefinition = "TEXT")
    private String aliReturnUrl;

    private String merchantId; //用户第三方关联id

    private String officialAccountOpenid; //公众号openid
}
